<template>
	<view class="President">
		<!-- 定位栏 -->
		<view class="location">
			<view class="picture"><image src="/static/Group41.png" mode="" class="picture_a"></image></view>
			<view class="address">{{ city.text }}</view>
			<!-- <view class="address" @click="position_A">{{ city.text }}</view> -->
			<!-- <view class="Aright"><image src="../../../static/right.png"></image></view> -->
		</view>
		<!-- 轮播 -->
		<view class="Top"><u-swiper height="285rpx" indicator :list="bannerList" @click="handleClickBanner" keyName="cover_image" :autoplay="true" circular></u-swiper></view>

		<!-- 轮播2 -->
		<view class="Top">
			<u-swiper :indicator="false" height="176rpx" :list="bannerList2" @click="handleClickBanner" keyName="cover_image" :autoplay="true" circular></u-swiper>
		</view>

		<!-- 陪诊金刚区 -->
		<view class="Escort">
			<view class="Seek" v-for="(item, index) in Jngang" @click="handleJingang(item)" :key="item.id"><image :src="item.cover_image" mode="" class="pupera_ag"></image></view>
		</view>

		<!-- 陪诊服务 -->
		<view class="zondesa">
			<view class="pupera_xt" v-for="(item, index) in PeizhneFuwu" :key="index" @click="handleFuwu(item)">
				<view class="juscenter"><image :src="item.cover_image" mode="" class="insertpuyer"></image></view>
				<view class="insertwords">{{ item.name }}</view>
			</view>
		</view>
		<view class="indexkfu" @click="kefu"><image src="../../../static/kefuindex.png" mode=""></image></view>
		<!-- 医院列表 -->
		<view v-for="(item, index) in list" :key="index" class="Bottombar" @click="jceny(item)">
			<view class="Bottompuper"><image :src="'https://zunxiang.rchz.top/' + item.cover_img" mode="" class="bottomnp"></image></view>
			<view class="Bottomworde">
				<view class="Bottom_onew">{{ item.name }}</view>
				<view class="diswods">
					<view class="S_display">{{ item.rank }}</view>
					<view class="A_display">{{ item.type }}</view>
				</view>
				<view class="D_display">重点科室：{{ item.key_department }}</view>
			</view>
		</view>
	</view>
</template>
<script>
export default {
	data() {
		return {
			city: {
				text: '嘉兴市',
				value: 934
			},
			list: [],
			serviceOption: [
				{
					id: 1,
					name: '诊前约号',
					image: '/static/Group42.png'
				},
				{
					id: 2,
					name: '代办问诊',
					image: '/static/Group43.png'
				},
				{
					id: 3,
					name: '送取结果',
					image: '/static/Group44.png'
				},
				{
					id: 4,
					name: '代办买药',
					image: '/static/Group45.png'
				},
				{
					id: 5,
					name: '全程陪诊',
					image: '/static/Group46.png'
				}
			],
			bannerList: [],
			bannerList2: [],
			// 陪诊金刚区
			Jngang: [],
			// 陪诊服务
			PeizhneFuwu: []
		};
	},
	onLoad() {
		// 初始化获取用户地址
		this.getAddressData();
	},
	async onShow() {
		await this.initAddress();
		// 医院列表
		this.getHospitalList();
		// 调用轮播图
		this.getBannerList();
		// 调用陪诊金刚区
		this.getJingang();
		// 调用陪着服务
		this.getPeizhenFuwu();
	},
	methods: {
		//初始化地址
		initAddress() {
			this.city = {
				text: '嘉兴市',
				value: 972
			};
			// if (uni.getStorageSync('city')) {
			// 	this.city = uni.getStorageSync('city');
			// } else {
			// 	this.city = {
			// 		text: '嘉兴市',
			// 		value: 972
			// 	};
			// }
		},
		getBannerList() {
			//获取轮播图接口 如果有的话替换url就行 如果是post 则把get改成post 改完之后放在onShow方法里面
			this.get('/api/Zrecduzp/lunbotuhuoqu', {
				status: 3
			}).then(res => {
				this.bannerList = res.data;
			});

			this.get('/api/Zrecduzp/lunbotuhuoqu', {
				status: 7
			}).then(res => {
				this.bannerList2 = res.data;
			});
		},
		getJingang() {
			//获取轮播图接口 如果有的话替换url就行 如果是post 则把get改成post 改完之后放在onShow方法里面
			this.get('/api/Zrecduzp/lunbotuhuoqu', {
				status: 5
			}).then(res => {
				this.Jngang = res.data;
			});
		},
		// 金刚区跳转
		handleJingang(item) {
			// 刷新缓存
			uni.removeStorageSync('hospital');
			uni.removeStorageSync('department');
			if (item.jump_path == 'null') {
				this.showTitle();
			} else {
				uni.navigateTo({
					url: item.jump_path + `?city=${this.city.value}`
				});
			}
		},
		// 获取指定地区的医院信息
		getHospitalList() {
			this.post('/api/Zrecduzp/huoquzhidingchengshiyiyuanliebiao', {
				city_id: this.city.value
			}).then(res => {
				this.list = res.data;
			});
		},
		getHospitalByDate(service_id) {
			this.post('/api/Zrecduzp/huoquyongyouzhidingfuwuleixingdeiyiyuan', {
				service_id: service_id
			}).then(res => {});
		},
		getPeizhenFuwu() {
			this.get('/api/Zrecduzp/lunbotuhuoqu', {
				status: 6
			}).then(res => {
				this.PeizhneFuwu = res.data;
			});
		},
		showTitle() {
			uni.showModal({
				title: '该功能正在开通中...',
				showCancel: false
			});
		},
		handleClickBanner(index) {
			if (this.bannerList[index].jump_path == 'null') {
				this.showTitle();
			} else {
				uni.navigateTo({
					url: this.bannerList[index].jump_path
				});
			}
		},
		getAddressData: function() {
			// user_id  id
			let self = this;
			let user_id = uni.getStorageSync('user_id');
			console.log('user_id-----', uni.getStorageSync('user_id'));
			self._get(
				'/api/logic/addressMsg',
				{
					user_id,
					id: 0
				},
				function(res) {
					console.log('ressssss', res);
					// 来是来了   就是没数据  这里假如说有数据的话，就把数据给一个变量，在页面上显示出来就可以了
					// 换个接口吧
				},
				function(err) {
					console.log(err);
				}
			);
		},
		kefu() {
			uni.makePhoneCall({
				phoneNumber: '4006573008'
			});
		},
		onShareAppMessage: function(res) {
			return {
				title: '安伈专业陪诊服务 期待您的光临！',
				path: '/pages/HomePage/HomePage',
				imageUrl: '/static/logo.jpg' //这个是分享的图片
			};
		},
		jceny(item) {
			// 清除科室信息
			uni.removeStorageSync('department');
			console.log(item);
			uni.setStorageSync('hospital', item);
			uni.navigateTo({
				url: `Enjoy?id=${item.id}`
			});
		},
		position_A() {
			uni.navigateTo({
				url: 'geographical/geographical'
			});
		},

		Dink(item) {
			if (!uni.getStorageSync('user_id')) {
				uni.switchTab({
					url: '/pages/My/My'
				});
				return;
			}
			const service = {
				service_name: item.name,
				service_id: item.id
			};
			uni.setStorageSync('./fillin', service);
			uni.navigateTo({
				url: './fillin'
			});
		},
		handleFuwu(item) {
			// 清除原有的科室信息
			uni.removeStorageSync('department');
			if (!uni.getStorageSync('user_id')) {
				uni.switchTab({
					url: '/pages/My/My'
				});
				return;
			}
			const service = {
				service_name: item.name,
				service_id: item.id
			};
			// 传递城市id,把服务类型id传递进去
			let service_id = item.jump_path.slice(12);
			this.getHospitalByDate(service_id);
			// 清除点击医院进入的缓存
			uni.removeStorageSync('hospital');
			uni.setStorageSync('./fillin', service);
			uni.navigateTo({
				url: item.jump_path
			});
		}
		// Ren_A() {
		// 	uni.reLaunch({
		// 		url: "../HomePage"
		// 	})
		// }
	}
};
</script>

<style lang="scss">
.left_T {
	width: 50rpx;
	height: 50rpx;
	margin-top: 50rpx;
	margin-left: 40rpx;
	display: inline-block;
	margin-left: -10rpx;
}

.indexkfu {
	position: fixed;
	top: 800rpx;
	right: 0rpx;

	image {
		box-shadow: 0px 0px 20px 2px rgba(0, 0, 0, 0.1);
		border-radius: 20rpx;
		width: 90rpx;
		height: 180rpx;
	}
}

/* 底部栏 */
.D_display {
	width: 340rpx;
	height: 50rpx;
	line-height: 50rpx;
	word-break: break-all;
	overflow: hidden;
	white-space: nowrap;
	text-overflow: ellipsis;
	font-size: 28rpx;
	color: #424f5e;
}

.A_display {
	color: #424f5e;
	height: 40rpx;
	line-height: 40rpx;
	margin: 10rpx;
	font-size: 28rpx;
}

.S_display {
	background-color: #5f5af7;
	color: #ffffff;
	font-size: 25rpx;
	border-radius: 20rpx;
	width: 90rpx;
	height: 40rpx;
	line-height: 40rpx;
	text-align: center;
	margin: 10rpx 10rpx 10rpx 0rpx;
	font-weight: 900;
}

.diswods {
	display: flex;
}

.Bottom_onew {
	font-size: 35rpx;
	font-weight: 900;
	margin-bottom: 10rpx;
	color: #424f5e;
}

.Bottomworde {
	margin-left: 30rpx;
	margin-top: 20rpx;
}

.bottomnp {
	width: 180rpx;
	height: 180rpx;
}

.Bottombar {
	border-radius: 30rpx;
	padding: 20rpx;
	background-color: #ffffff;
	width: 620rpx;
	margin-left: 50rpx;
	margin-top: 30rpx;
	display: flex;
	box-shadow: 0px 0px 20px 2px rgba(0, 0, 0, 0.1);
}

/*  中间选项栏样式*/
.insertwords {
	text-align: center;
	font-size: 24rpx;
	font-weight: 800;
	color: #424f5e;
	margin-top: 10rpx;
}

.insertpuyer {
	width: 100rpx;
	height: 100rpx;
	margin-right: 10rpx;
}

.zondesa {
	display: flex;
	// width: 620rpx;
	margin-left: 20rpx;
	margin-right: 20rpx;
	margin-top: 30rpx;
	justify-content: space-between;
}

/* 中间图片 */
.pupera_bg {
	width: 640rpx;
	height: 280rpx;
	margin-left: 55rpx;
	margin-top: -10rpx;
}

/* 定位栏样式 */
.Aright {
	image {
		margin-top: 16rpx;
		width: 30rpx;
		height: 30rpx;
		margin-left: 10rpx;
	}
}

.address {
	font-size: 30rpx;
	color: #424f5e;
	margin-left: 20rpx;
	margin-top: 10rpx;
}

.picture {
	margin-left: 55rpx;
}

.location {
	display: flex;
	justify-content: flex-start;
}

.picture_a {
	width: 60rpx;
	height: 60rpx;
	margin-top: 5rpx;
}

/* 轮播图样式 */
.Top {
	padding: 20rpx;
	// width: 700rpx;
}

/* 金刚区样式 */
.Escort {
	// margin: 0rpx 20rpx 0rpx 20rpx;
	display: flex;
	justify-content: space-between;
	margin: 0rpx 20rpx;
}

/* 就医陪护样式 */
.pupera_ag {
	width: 345rpx;
	height: 168rpx;
	border-radius: 10rpx;
}

.Topone {
	width: 280rpx;
	text-align: left;
	font-size: 45rpx;
	font-weight: 900;
	margin-left: 40rpx;
}

.Toptwo {
	color: #5f5af7;
	font-size: 35rpx;
	font-weight: 900;
	margin-left: -50rpx;
	margin-top: 40rpx;
}

.President {
	background-color: #f9f9f9;
}
</style>
